package com.md04.mapper;

import com.md04.entity.Dept;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

//相当于采购员
public interface DeptMapper {
    //mapper是接口
    //数据访问层，就是对数据的增、删、改、查
    //查询全部
    @Select("select * from dept")
    List<Dept> selectAllDept();

    @Select("select * from dept where dept_id=#{id}")
    Dept selectOneById(int id);

    @Select("delete from dept where dept_id =#{id}")
    int deleteById(int id);

    //增加
    @Insert("insert into dept(dept_name) values(#{deptName})")
    void addOne(Dept dept);

    //删除
    @Update("update dept set dept_name=#{deptName} where dept_id =#{deptId}")
    void updateOne(Dept dept);

}
